<template>
  <div class="container">
    <mt-header fixed :title="$route.meta.title">
      <span slot="left" @click="$router.back()" v-show="$route.path!=='/home'">
        <mt-button icon="back">返回</mt-button>
      </span>
    </mt-header>
    <transition name="fade">
      <router-view></router-view>
    </transition>
    <tabbar></tabbar>
  </div>
</template>

<script>
import Tabbar from '@/components/Tabbar.vue'
import { mapActions } from 'vuex'
export default {
  data () {
    return {      
    }
  },
  created () {    
    this.checkLogin()
  },
  watch: {   
  },
  methods: {
    ...mapActions("user",["islogin"]),// `mapActions` 支持载荷将 `this.islogin` 映射为 `this.$store.dispatch('islogin')`    
   
    async checkLogin () {      
      try {
        let result = await this.islogin();
        if(result.code == 1){
          this.$toast("用户已经登录")
        }
      } catch (error) {
        this.$messagebox("检验用户登录",error);
      }  
    }
  },
  components: {
    Tabbar
  }
}
</script>

<style lang="scss">

#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  box-sizing: border-box;
}

.container {
  padding-top: 40px;
  padding-bottom: 60px;
  overflow-x: hidden;
}

.fade-enter {
  opacity: 0;
  transform: translateX(100%);
}

.fade-leave-to {
  opacity: 0;
  transform: translateX(-100%);
  position: absolute;
}

.fade-enter-active,
.fade-leave-active {
  transition: all 0.5s ease;
}
label{
  font-size: 14px;
  margin-bottom: 0px;
}
</style>